package com.tuanzi.loan.business.service.application.impl;

import com.tuanzi.loan.business.entity.application.LoanApplicationExportGroup;
import com.tuanzi.loan.business.repository.application.LoanApplicationExportGroupRepository;
import com.tuanzi.loan.business.service.application.LoanApplicationExportGroupService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.core.service.CommonServiceImpl;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.application.LoanApplicationExportGroupRequest;
import com.tuanzi.loan.vo.response.application.LoanApplicationExportGroupResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Auther: hequnayu
 * @Date: 2019/7/30 15:55
 * @Description:
 */
@Slf4j
@Debug
@Service
@Transactional
public class LoanApplicationExportGroupServiceImpl extends CommonServiceImpl<LoanApplicationExportGroup,Long> implements LoanApplicationExportGroupService {

    @Autowired
    private LoanApplicationExportGroupRepository groupRepository;

    @Override
    protected JpaRepository<LoanApplicationExportGroup, Long> getRepository() {
        return groupRepository;
    }

    @Override
    public Page<LoanApplicationExportGroupResponse> list(PageSearcher<LoanApplicationExportGroupRequest> pageSearcher) {
        return groupRepository.list(pageSearcher.getSearchCondition(), pageSearcher.getPageable());
    }

    @Override
    public List<LoanApplicationExportGroup> findByPageId(Long pageId) {
        return groupRepository.findAllByPageId(pageId);
    }

    @Override
    public LoanApplicationExportGroup findByGroupIdAndType(Integer groupId,Integer type) {
        return groupRepository.findByGroupIdAndType(groupId,type);
    }

    @Override
    public Integer getBiggestGroupId() {
        return groupRepository.getBiggestGroupId();
    }
}
